<%--
  ~ Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
  ~ Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
  ~ Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
  ~ Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
  ~ Vestibulum commodo. Ut rhoncus gravida arcu.
  --%>

<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2017/5/22
  Time: 9:03
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <jsp:include page="../../head.jsp"/>
    <title>基础数据维护</title>
    <script type="text/javascript">
        var openSetting = {
                large : {
                    width:1024,
                    height:600
                },
                middle : {
                    width:800,
                    height:350
                },
                small : {
                    width:450,
                    height:310
                }
        };
        var getOpenSetting = function(type){
            var want = {};
            var matchSetting = openSetting[type];
            want.width = matchSetting.width;
            want.height = matchSetting.height;
            want.left = matchSetting.width;
            want.left = (window.screen.availWidth - matchSetting.width) / 2;
            want.top = (window.screen.availHeight - matchSetting.height) / 2;
            return want;
        };

        var formSetting = {
            title: "查询信息",
            module: 'query',
            columns: [
                {
                    index: "code",
                    name: "code",
                    label: "代码"
                }, {
                    index: "name",
                    name: "name",
                    label: "名称"
                }, {
                    index: "status",
                    name: "status",
                    label: "状态",
                    type: "dropdown",
                    data: [["注销", "0"], ["启用", "1"]],
                    op: "eq",
                    minLength: 0
                }
            ],
            buttons: {
                custom: [
                    {
                        id: "addBtn",
                        value: "添加组",
                        click: function () {
                            var ost = getOpenSetting('small');
                            layer.open({
                                           title:"新增字典组",
                                           type:2,
                                           content:"addPage",
                                           area: [ost.width+'px', ost.height+'px']
                                       });
                        }
                    }, {
                        id: "addBtn",
                        value: "添加字典",
                        click: function () {
                            var dtgId = $("#dictionaryGroupDataGrid").gridMethods().getSelectRow().id;
                            if(!dtgId){
                                layer.msg("先选中一行");
                                return;
                            }
                            var rowData = $("#dictionaryGroupDataGrid").gridMethods().getSelectRow();
                            var url = "../mainPage?groupId=" + rowData.id;
                            var ost = getOpenSetting('large');
                            layer.open({
                                           title: "【"+rowData.name+"】字典管理",
                                           type:2,
                                           content:url,
                                           area: [ost.width+'px', ost.height+'px']
                                       });
                        }
                    }, {
                        id: "editBtn",
                        value: "修改",
                        click: function () {
                            var rowData = $("#dictionaryGroupDataGrid").gridMethods().getSelectRow();
                            var dtgId = rowData.id;
                            if(!dtgId){
                                layer.msg("先选中一行");
                                return;
                            }
                            var ost = getOpenSetting('small');
                            layer.open({
                                           title:"修改【"+ rowData.name + "】",
                                           type:2,
                                           content:"addPage?dtgId="+ dtgId,
                                           area: [ost.width+'px', ost.height+'px']
                                       });
                        }
                    }]
            },
            grid: {
                id: "dictionaryGroupDataGrid",
                title: "查询结果",
                url: "listData",
                multiselect: false,
                colModel: [{
                    index: "id",
                    name: "id",
                    hidden: true
                }, {
                    index: "parentName",
                    name: "parentName",
                    label: "父字典组"
                }, {
                    index: "code",
                    name: "code",
                    label: "代码"
                }, {
                    index: "name",
                    name: "name",
                    label: "名称"
                }, {
                    index: "decript",
                    name: "decript",
                    label: "描述"
                }, {
                    index: "status",
                    name: "status",
                    label: "状态",
                    formatter: function (cellvalue, options, rowObject) {
                        if (cellvalue === "0") {
                            return "注销";
                        } else if (cellvalue === "1") {
                            return "启用";
                        } else {
                            return "";
                        }
                    }
                }, {
                    index: "creator",
                    name: "creator",
                    label: "创建人"
                }, {
                    index: "createTime",
                    name: "createTime",
                    label: "创建时间"
                }, {
                    index: "modifier",
                    name: "modifier",
                    label: "最后一次修改人"
                }, {
                    index: "modifyTime",
                    name: "modifyTime",
                    label: "最后一次修改时间"
                }],
                sortname: "code",
                sortorder: "asc",
                subGrid : true,
                subGridUrl : "../findByGroupId",
                subGridModel : [{
                    name:["字典代码","字典名","描述","创建人","创建时间","修改人","修改时间"],
                    width:[160,100,200,100,100,100,100,100]
                }]
            }
        };
        $(document).ready(function () {
            $("#dictionaryGroupDataTable").mrdForm(formSetting);
            $("backBtn").hide();
        });

        function reloadGridData(){
            $("#dictionaryGroupDataGrid").gridMethods().reload();
        }
    </script>
</head>
<body>
<div id="dictionaryGroupDataTable"></div>
</body>
</html>
